public class ReverseString {
    public static void main(String[] args) {
        String s = "The River Thames is the most important waterway in Great Britain";
        String[] s1 = s.split(" ");
        StringBuilder result = new StringBuilder();
        int length = s1.length;
        for (int i = length - 1; i >= 0; i--) {
            result.append(s1[i]);
            if (i != 0) {
                result.append(" ");
            }
        }
        System.out.println(result.toString());
    }
}
